<div class="jxksbmk" style="height: 100%;width:100%;overflow:auto;">
    <div class="button-group-head" style="">
        <span class="hrp-btn hrp-btn-add"  id="openDialog"><i class="fa fa-plus" style="padding-right: 4px;"></i>添加</span>
        <span  class="hrp-btn hrp-btn-refresh"><i class="fa fa-refresh" style="padding-right: 4px;"></i>刷新</span>
    </div>
    <div class="jxkhzbk-toolbar">

        <span style="padding-top: 4px;height: 40px;float: right;padding-right: 20px;">
            <input id="cc" name="dept">
        </span>
        <span style="height:40px;line-height: 40px;float: right;padding-right: 5px;font-size:14px;">科室类别:</span>
    </div>
    <div>
        <table id="dg" class="easyui-datagrid" style="width:100%;">
            <!--<thead>-->
            <!--<tr>-->
            <!--<th  width="15%">Item ID(15%)</th>-->
            <!--<th  width="15%">Product(15%)</th>-->
            <!--<th  width="15%">List Price(15%)</th>-->
            <!--<th  width="15%">List Price(15%)</th>-->
            <!--<th width="15%">List Price(15%)</th>-->
            <!--</tr>-->
            <!--</thead>-->
        </table>
    </div>







    <div id="editActionDialog"  class="ss-dialog" style="height:250px;">
        <span class="ss-dialog-close" style="">X</span>
        <div class="ss-dialog-head" style="">
            添加
        </div>
        <div class="ss-dialog-content">
            <div class="row" style="height: 60px;">
                <input type="hidden" id="idkey" value="-1"/>
                <span style="width:17%;height:60px;line-height:60px;float:left;text-align: center;">科室类别</span>
                <span style="width:33%;float:left;padding-top: 10px;"><input  id="kslb" type="text" value="0" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:17%;height:60px;line-height:60px;float:left;text-align: center;">科室代码</span>
                <span style="width:33%;float:left;"><input type="text" disabled="disabled" id="jxksdm" style="margin: 0;padding: 0;height:35px;margin-top:10px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;"  /></span>
            </div>
            <div class="row" style="height: 60px;">
                <span style="width:17%;height:60px;line-height:60px;float:left;text-align: center;">科室名称</span>
                <span style="width:33%;float:left;padding-top: 10px;"><input id="jxksmc" type="text" placeholder="输入绩效科室名称" style="margin: 0;padding: 0;height:35px;border:1px solid #ccc;box-shadow: 1px 1px 1px #eee;width:100%;" /></span>
                <span style="width:17%;height:60px;line-height:60px;float:left;text-align: center;">停用标志</span>
                <span style="width:33%;float:left;padding-top: 21px;font-size: 14px;cursor: pointer;">
                    <span class="self-radio" data-radio="true" id="qy" data-value="1"><i class="fa fa-dot-circle-o"></i>启用</span>
                    <span class="self-radio" id="ty" data-value="0"><i class="fa fa-circle-o"></i>停用</span>
                </span>
            </div>

        </div>
        <div  class="ss-dialog-head" style="">
            <span class="hrp-btn hrp-btn-delete" style="float: right;" id="btn-cancel"><i class="fa fa-close" style="padding-right: 4px;"></i>取消</span>
            <span class="hrp-btn hrp-btn-add" style="float: right;" id="btn-save"><i class="fa fa-plus" style="padding-right: 4px;"></i>添加</span>
        </div>
    </div>
    <div id="mask-model" class="mask-model" style=""></div>



</div>
<script type="text/javascript">


    var dHeight = $(".jxksbmk").height()-82;

    var UserIndexPage={
        init:function () {
            this.initEvnets();
            //this.initGrid();
            this.initCombox();
            this.initZblb();
        },
        initEvnets:function () {

            var that = this;

            $(window).resize(function () {
                $('#dg').datagrid("resize")
            })

            $("#openDialog").on("click",function () {
                $("#idkey").val("-1");
                $.post("jxkhzb/getMaxZbid",function (result) {
                    $("#zbdm").val(result);
                })
                $('#editActionDialog').slideDown(300);
                $("#mask-model").slideDown(300);
            })

            $(".ss-dialog-close").on("click",function () {
                $('#editActionDialog').slideUp(300);
                $("#mask-model").slideUp(300);
            })

            $("#btn-save").on("click",function () {
                that.saveJxksData();
            })

            $("#btn-cancel").on("click",function () {
                $('#editActionDialog').slideUp(300);
                $("#mask-model").slideUp(300);
            })


            //修改
            $(".jxksbmk").on("click",".btn-edit",function () {
                var id = $(this).attr("data-id");
                var jxksdm = $(this).attr("data-jxksdm");
                var jxksmc = $(this).attr("data-jxksmc");
                var tybz = $(this).attr("data-tybz");
                var kslb = $(this).attr("data-kslb");

                $("#idkey").val(id);

                $("#jxksdm").val(jxksdm);
                $("#jxksmc").val(jxksmc);

                $(".self-radio[data-value='" + tybz + "']").click();


                $('#kslb').combobox({
                    url:"common/getDicList",
                    queryParams: {
                        "id": kslb,
                        "lbdm": "1"
                    },
                    valueField:'id',
                    textField:'text',
                    width:200,
                    panelHeight:100,
                    onSelect:function (record) {
                        //that.getJxksdm(record.id);
                    },
                    onLoadSuccess:function () {

                    }
                });

                $('#editActionDialog').slideDown(300);
                $("#mask-model").slideDown(300);
            });

        },
        saveJxksData:function () {
            var kslb=$('#kslb').combobox("getValue");
            var  jxksdm=$("#jxksdm").val();
            var jxksmc = $("#jxksmc").val();
            if(jxksmc==""){
                $.messager.show({title: '提示', msg: '请输入绩效科室名称', timeout: 1000, showType: 'slide'});
                return
            }
            var tybz = $(".self-radio[data-radio='true']").attr("data-value");

            $.post("jxksdm/saveJxksData", {
                "kslb": kslb,
                "jxksdm": jxksdm,
                "jxksmc": jxksmc,
                "tybz": tybz,
                "id":$("#idkey").val()
            }, function (result) {
                if (result.status == 200) {
                    $('#editActionDialog').slideUp(300);
                    $("#mask-model").slideUp(300);
                    $.messager.show({title: '提示', msg: '保存成功', timeout: 1000, showType: 'slide'});
                } else {
                    $.messager.show({title: '提示', msg: '保存失败', timeout: 1000, showType: 'slide'});
                }
            })

        },
        initCombox:function () {

            var that=this;

            $('#kslb').combobox({
                url:"common/getDicList",
                queryParams: {
                    "id": -1,
                    "lbdm": "1"
                },
                valueField:'id',
                textField:'text',
                width:200,
                panelHeight:100,
                onSelect:function (record) {
                    that.getJxksdm(record.id);
                },
                onLoadSuccess:function () {

                }
            });
        },
        getJxksdm:function (kslb) {
            $.post("jxksdm/getJxksdm",{"kslb":kslb},function (result) {
                if(result.status==200){
                    $("#jxksdm").val(result.data);
                }else{
                    $.messager.show({title: '提示', msg: '绩效科室代码获取失败', timeout: 1000, showType: 'slide'});
                }
            })
        },
        initZblb:function () {
            var that = this;
            $('#cc').combobox({
                url:"common/getKslbList",
                valueField:'id',
                textField:'text',
                onSelect:function (record) {
                    that.initGrid(record.id);
                },
                onLoadSuccess:function () {

                }
            });
        },
        initGrid:function (kslb) {
            $('#dg').datagrid({
                url: "jxksdm/getJxksdmByPage",
                queryParams: {
                    kslb: kslb
                },
                pagination: true,
                singleSelect: true,
                height:dHeight,   //表格高度，可指定高度，可自动
                pageNumber: 1,
                pageSize: 15,
                pageList: [15, 30],
                fitColumns:true,
                loadMsg: "正在加载数据",
                nowrap: false,
                striped: true,  //奇偶行是否使用不同的颜色
                columns:[
                    [
                        {field:'id',title:'编号',width:"20%"},
                        {field:'jxksdm',title:'科室代码',width:"25%"},
                        {field:'jxksmc',title:'科室名称',width:"25%"},
                        {field:'py',title:'拼音',width:"20%"},
                        {
                            field: 'edit', title: '操作', width: "10%",
                            formatter: function (value, row, index) {
                                return "<a class='btn-edit' href='#' data-id='"+row.id+"'  data-jxksdm='"+row.jxksdm+"' data-jxksmc='"+row.jxksmc+"' data-tybz='"+row.tybz+"'  data-kslb='"+row.kslb+"'>修改</a>"
                            }
                        }
                    ]
                ]
            });

        }
    }
    $(function () {
        UserIndexPage.init();
    })
</script>